package com.test;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;
import java.util.StringTokenizer;

/**
 * @author:wesley
 */
public class WordCountMapper extends Mapper<LongWritable, Text,Text,IntWritable>{

    private Text word = new Text();

    public void map(LongWritable key, Text value, Context context)
            throws IOException, InterruptedException {

        StringTokenizer itr = new StringTokenizer(value.toString());

        while (itr.hasMoreTokens()) {
            this.word.set(itr.nextToken());
            context.write(this.word,  new IntWritable(1));
        }
    }


}
